package com.backend.mapper;

import com.backend.pojo.entity.LeaveRequest;
import com.backend.pojo.vo.LeaveRequestVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface examineMapper {
    /*查询未批请假名单*/
    @Select("select * from sms.leave_requests where status = 0")
    List<LeaveRequestVO> getLeaves();

    /*通过id获取假单信息*/
    @Select("select * from sms.leave_requests where user_id = #{stuId}")
    LeaveRequest getLeavesById(String stuId);

    /*更新假单状态*/
    @Update("update sms.leave_requests set status = #{status} where user_id = #{userId}")
    void updateStatus(LeaveRequest leaveRequest);

    /*根据id查询请假单详情*/
    @Select("select * from sms.leave_requests where user_id = #{userId}")
    LeaveRequestVO getById(String stuId);

    /*根据id*/
    @Delete("delete from sms.leave_requests where user_id = #{stuId}")
    void deleteById(String stuId);

    List<LeaveRequestVO> getByCondition(String condition);
}
